{extend name="template/base" /}
{block name="nav"}{/block}
{block name="content"}
<link rel="stylesheet" href="/static/admin/lib/lightbox2/css/lightbox.min.css">
	<div class="toptip">
		<h2>提示：</h2>
		<p>
		  点击上传标志，选择导入人员信息的表格，确认上传，选择相应项目组和公司<br>
		</p>
	</div>
	<legend><i class="Hui-iconfont">&#xe600;</i>批量添加</legend>
<div class="page-container">
    <div class="form form-horizontal">
        <div class="row cl">
            <label class="form-label f-l ml-20"><span class="c-red">*</span>EXCEL：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" id="upload" name='file' placeholder="请点击后面的上传按钮" datatype="*" nullmsg="请填写图片url" style="width: 50%">
				
			<!--	<select name="p_cid" id="p_cid" placeholder="部门" class="input-text" style="width: 20%">
					{volist name="department" id="subc"}
					<option value="{$subc['id']}" >{$subc['name']}</option>
					{/volist}
				</select>-->
                <button type="button" class="btn btn-primary radius" onclick="layer_open('文件上传','/admin/upload/uploadLocal/id/upload.html')">上传</button>
                <a href='javascript:;' type="button" class="btn btn-success radius" data-lightbox="preview">确认</a>
                <a class="btn btn-primary radius mr-5" href="__STATIC__/files/renyuan.xls" target='_blank' > 标准模板下载</a>
				<br>
				<!--部门<select class="combox form-control" name='tree' id="tree">-->
 <!---->
                    <!--{volist name="tree" id="vo"}-->
                    <!--<option value="{$vo.id}"> {$vo.name}</option>-->
                    <!--{/volist}-->
                <!--</select>-->
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl specialty" {if !isset($vo.specialty_id)}style=" display: none; "{/if}>
            <label class="form-label f-l ml-20">专业：</label>
            <div class="formControls col-xs-8 col-sm-5">
                <div class="select-box">
                    <select class="select" datatype="*" needle="needle" name="specialtyid" id="specialtyid" class="select  combox form-control" datatype="*" nullmsg="专业不能为空" >
                        <option value="0">请选择专业</option>
                        {if isset($specialtyList)}
                        {volist name="specialtyList" id="sList"}
                        <option value="{$sList.id}">{$sList.name}</option>
                        {/volist}
                        {/if}
                    </select>
                </div>
            </div>
             <div class="col-xs-offset-4"></div>
        </div>
        <div class="row cl">
            <label class="form-label f-l ml-20"><span class="c-red">*</span>项目组：</label>
            <div class="formControls col-xs-8 col-sm-5">
                <div class="select-box sbox select-combox">
                    <select class="select combox form-control autoloaditem"  autoload="/admin/common_ajax/ajaxGetGroup/" onclick="getSpecialty(this.value)"  name='project' id="project" ref="company" refUrl="/admin/common_ajax/ajaxGetCompany/projectid/{value}/" callback="getSectionContent">
                        <option value>请选择科目</option>
                    </select>
                </div>
            </div>
            <div class="col-xs-offset-4"></div>
        </div>
        <div class="row cl">
            <label class="form-label f-l ml-20"><span class="c-red">*</span>公司：</label>
            <div class="formControls col-xs-8 col-sm-5">
                <div class="select-box">
                    <select class="select combox form-control" name='company' id="company">

                    </select>
                </div>
            </div>
            <div class="col-xs-offset-4"></div>
        </div>
		<div class="row cl">
          <img src="/static/admin/images/exceldemo.png" width="100%" >
          <br />
        </div>
		
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    function getSpecialty(e){
        $.post('/admin/User/getOnSpecialtyByProjectId',
                {'project_id' : e},
                function(data){
                    if (data.on_specialty==1){
                        $('.specialty').show();
                    }else {
                        $('.specialty').hide();
                    }
                });
    }
    $(function () {
        $("[name='status'][value='{$vo.status ?? '1'}']").attr("checked",true);

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
		
		$('.btn-success').click(function(){
		var bel = $('#upload').val();
		var prect= $('#project option:selected').val();
		var company= $('#company option:selected').val();
		var specialtyid= $('#specialtyid option:selected').val();

		//var p_cid = $('#p_cid').val();,deid:p_cid
		if(bel!=''){
		    if(!prect){
                layer.msg('请选择项目组', {time: 2000, icon:5});
            }
			 $.post("/admin/user/batchimport.html",{file:bel,project:prect,company:company,specialtyid:specialtyid},function(result){
		
                 result = result.replace(/(^\s*)|(\s*$)/g, "");
				if(result=='    y' || result=='y'){
					$('#upload').val('');
					layer.msg('导入成功', {time: 2000, icon:6});
//                    layer_close();
				}else {
                    result=  $.trim(result);
                    result = result.substr(0, result.length - 1);
                    layer.msg('导入失败，用户名'+result+'相同,请重新上传', {time: 2000, icon:6});
                }
                 result=  $.trim(result);

				if (result=='    kaoshi2y'){

                }
			  });
		 }
		});

        $("#form").Validform({
            tiptype:2,
            ajaxPost:true,
            showAllError:true,
            callback:function(ret){
                ajax_progress(ret);
            }
        });
    })
</script>
{/block}